package com.csg.boot.starter.builder;

import com.csg.boot.starter.constant.SwaggerProperties;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.Parameter;

/**
 * @author george
 */
public class ParameterBuilder implements BaseBuilder<Parameter, SwaggerProperties.ParametersProperties> {

    private static ParameterBuilder builder = new ParameterBuilder();

    private ParameterBuilder() {
    }

    public static ParameterBuilder getInstance() {
        return builder;
    }

    @Override
    public Parameter build(SwaggerProperties.ParametersProperties properties) {
        return new springfox.documentation.builders.ParameterBuilder()
                .name(properties.getName())
                .description(properties.getDescription())
                .defaultValue(properties.getDefaultValue())
                .required(properties.getRequired())
                .parameterType(properties.getParamType())
                .parameterAccess(properties.getParamAccess())
                .modelRef(new ModelRef(properties.getModelRef()))
                .hidden(properties.getHidden())
                .pattern(properties.getPattern())
                .collectionFormat(properties.getCollectionFormat())
                .allowEmptyValue(properties.getAllowEmptyValue())
                .order(properties.getOrder())
                .build();
    }
}